package com.example.uit_management;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class Menu_Activity extends Activity {
	// array string menu
	private String[] values = new String[] { 
			"Thông Báo",
			"Đăng kí môn học",
			"Đăng kí môn học (version2)",
			"Điểm",
			"Thời khóa biểu",
			"Thời khóa biểu(version2)",
			"Thông tin"
		  	  };
	static ProgressDialog dialog;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);        
        setContentView(R.layout.activity_menu);
        //////////////////////////////
        //Set List view (Menu)   
        ListView listView = (ListView) findViewById(R.id.list_activity_menu);   
        Show_listView(listView);
        // Listener for item list view
        listView.setOnItemClickListener(new OnItemClickListener() {
        	  @Override
        	  public void onItemClick(AdapterView<?> parent, View view,
        	    int position, long id) {
        	   /* Toast.makeText(getApplicationContext(),
        	      "Click ListItem Number " + position , Toast.LENGTH_LONG)
        	      .show();*/
        		 String s =(String) ((TextView) view.findViewById(R.id.textView_menu)).getText();
        		 if(s.equals("Đăng kí môn học"))	 {
        			 // Show intent Dang ki mon hoc 
        			//dialog
        			 dialog = ProgressDialog.show(Menu_Activity.this, "",
        		                "Please wait for few seconds...", true);
      			startActivity(new Intent(getApplicationContext(),Activity_list_registry.class));	              		
        		 }else if(s.equals("Thời khóa biểu")){
        			 // Show intent Thoi khoa bieu     
        			 //dialog        			
        			 dialog = ProgressDialog.show(Menu_Activity.this, "",
     		                "Please wait for few seconds...", true);
               		startActivity(new Intent(getApplicationContext(),Activity_list_schedule.class));	
            	  }else if(s.equals("Điểm")){  
            		  dialog = ProgressDialog.show(Menu_Activity.this, "",
      		                "Please wait for few seconds...", true);
                  	Intent intent = new Intent(getApplicationContext(),Activity_Score.class);
                  	startActivity(intent);
            	  }else if(s.equals("Thông tin")){
            		  dialog = ProgressDialog.show(Menu_Activity.this, "",
        		                "Please wait for few seconds...", true);
                    	Intent intent = new Intent(getApplicationContext(),Activity_ImformationStudent.class);
                    	startActivity(intent);
            	  }else if(s.equals("Thời khóa biểu(version2)")){
        		  dialog = ProgressDialog.show(Menu_Activity.this, "",
    		                "Please wait for few seconds...", true);
                	Intent intent = new Intent(getApplicationContext(),Activity_list_schedule_vs2.class);
                	startActivity(intent);
            	  }else if(s.equals("Đăng kí môn học (version2)")){
            		  dialog = ProgressDialog.show(Menu_Activity.this, "",
      		                "Please wait for few seconds...", true);
                  	Intent intent = new Intent(getApplicationContext(),Activity_list_registry_vs2.class);
                  	startActivity(intent); 
                  
              	  }
        	  }
        	}); 
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_menu, menu);
        return true;
    }
    public void Show_listView(ListView listView){    	 	

    	// First paramenter - Context
    	// Second parameter - Layout for the row
    	// Third parameter - ID of the TextView to which the data is written
    	// Forth - the Array of data    	
    	// Assign adapter to ListView
    	listView.setAdapter(new ArrayAdapter<String>(this,R.layout.menu_row, R.id.textView_menu, values)); 
    }
}
